local skynet = require "skynet"
local filelog = require "filelog"
local tabletool = require "tabletool"
local configdao = require "configdao"
local cluster = require "skynet.cluster"
require "skynet.manager"
require "pubenum"

skynet.start(function()
	skynet.newservice("nodelog")
	local confsharesvr = skynet.newservice("confshare")
	skynet.call(confsharesvr, "lua", "start")
	local ernnnode = configdao.get_cfgsvrs_key("ernnnode")
	if ernnnode and ernnnode.debug_console_port then
		skynet.newservice("debug_console",ernnnode.debug_console_port)
	end
	local timersvr = skynet.newservice("timercenter")
    skynet.call(timersvr, "lua", "init", ernnnode.timersize)

    skynet.name(".nodeuuid", skynet.uniqueservice("nodeuuid"))

    ---方便拉取配置
    skynet.name(".gmmqredis", skynet.newservice("redisdb"))	
	skynet.call(".gmmqredis", "lua", "init", configdao.get_cfgsvrs_key("gmmqredis"))
	
	skynet.name(".tablerecordlog", skynet.newservice("tabledatalog"))
	skynet.call(".tablerecordlog", "lua", "init", "tablerecord")

	skynet.name(".tablereplaylog", skynet.newservice("tabledatalog"))
	skynet.call(".tablereplaylog", "lua", "init", "tablereplay")

	skynet.name(".robotmgr", skynet.uniqueservice("robotmgr"))

	skynet.name(".slotmgr", skynet.newservice("slotmgr"))

	--游戏钻石日志服务
    skynet.name(".diamondlog", skynet.newservice("datalog"))
	skynet.call(".diamondlog", "lua", "init", "diamond")
	
	skynet.name(".router", skynet.uniqueservice("router") )	
	cluster.open("ernnnode")
	skynet.call(".router", "lua", "start", ernnnode)
	cluster.send("gatenode", ".router", "gamenode_init", skynet.getenv("nodename"))
	skynet.exit()
end)